from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def hello_django(request): # 视图函数第一个参数必须是request
    return HttpResponse("hello django!") # 不能直接返回一个字符串，需要返回一个HttpResponse对象

def hello_django2(request):
    dict_data = {
        "name": "张三",
        "info": {
            "gender": "男",
            "age": 18,
            "address": "北京",
            "score": 79
        },
        "hobby": ["篮球", "足球", "乒乓球"],
        "func":test,
        "p":Person()

    }
    return render(request, "hello.html", dict_data) # 返回一个html页面

def test():
    return "test函数查询"

class Person:
    def __init__(self):
        self.name = "李四"
        self.age = 20
    def introduce(self):
        return "我叫%s,今年%d岁" % (self.name, self.age)